package 算法.递归;

public class 阶乘 {
    public static void main(String[] args) {
        // 递归
        System.out.println(getFactorialRecursion(5));

        // 循环的方法求5的阶乘
        int s=1;
        for (int i = 1; i <= 5; i++) {
            s=s*i;
        }
        System.out.println(s);
    }

    public static int getFactorialRecursion(int number){
        if (number == 1) {
            return 1;
        }
        return number*getFactorialRecursion(number-1);
    }
}
